package com.jml.FenBuShiLock;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {

	@Autowired
	private DistributedLock distributedLock;

	@RequestMapping("/isZKAlive")
	@ResponseBody
	public String isZKAlive() {

		/*boolean isAlive = ZKCurator.isZkAlive();
		String result=isAlive?"连接":"断开";
		return result;*/
		return null;
	}

	public void testGetLock(){
		//获取锁，如果没有获取到会一直在getlock方法中进行循环直到获取
		distributedLock.getLock();
		distributedLock.releaseLock();//在最后或者return前调用
	}
}
